package com.warmheart.core.pool;

import java.util.function.Supplier;

import javax.validation.constraints.NotNull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class WhSupplier<T> implements Supplier<T> {

    private static Logger logger = LoggerFactory.getLogger(WhSupplier.class);

    private String remarks;

    private Supplier<T> supplier;

    WhSupplier(@NotNull String remarks, @NotNull Supplier<T> supplier) {
        super();
        this.remarks = remarks;
        this.supplier = supplier;
    }

    String getRemarks() {
        return remarks;
    }

    @Override
    public T get() {
        logger.info("----------------------------" + this.remarks + "开始----------------------------");
        T result = this.supplier.get();
        logger.info("----------------------------" + this.remarks + "结束----------------------------");
        return result;
    }
}
